// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package ecommerce.news;

import include.get_sql.getInsertSql;
import include.nseer_cookie.counter;
import include.nseer_cookie.exchange;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataNumber;
import validata.ValidataTag;

public class check_delete_ok extends HttpServlet
{

	public check_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		try
		{
			HttpSession dbSession = request.getSession();
			JspFactory _jspxFactory = JspFactory.getDefaultFactory();
			javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
			javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
			HttpSession session = request.getSession();
			nseer_db_backup1 ecommerce_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 ecommerce_db1 = new nseer_db_backup1(dbApplication);
			ValidataNumber validata = new ValidataNumber();
			ValidataTag vt = new ValidataTag();
			counter count = new counter(dbApplication);
			getInsertSql getInsertSql = new getInsertSql();
			if (ecommerce_db.conn((String)dbSession.getAttribute("unit_db_name")) && ecommerce_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_ID = request.getParameter("config_ID");
				String news_ID = request.getParameter("news_ID");
				String choice = request.getParameter("choice");
				String bodyd = new String(request.getParameter("opinion").getBytes("UTF-8"), "UTF-8");
				String opinion = exchange.toHtml(bodyd);
				String checker_ID = request.getParameter("checker_ID");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				String sql6 = (new StringBuilder("select id from ecommerce_workflow where object_ID='")).append(news_ID).append("' and ((check_tag='0' and config_id<'").append(config_ID).append("') or (check_tag='1' and config_id='").append(config_ID).append("'))").toString();
				ResultSet rs6 = ecommerce_db.executeQuery(sql6);
				if (!rs6.next())
				{
					if (vt.validata((String)session.getAttribute("unit_db_name"), "ecommerce_news", "news_ID", news_ID, "check_tag").equals("0"))
					{
						if (choice != null)
						{
							if (choice.equals(""))
							{
								String sql = (new StringBuilder("update ecommerce_news set opinion='")).append(opinion).append("',check_tag='9',excel_tag='9' where news_ID='").append(news_ID).append("'").toString();
								ecommerce_db.executeUpdate(sql);
								sql = (new StringBuilder("delete from ecommerce_workflow where object_ID='")).append(news_ID).append("'").toString();
								ecommerce_db.executeUpdate(sql);
							} else
							{
								sql6 = (new StringBuilder("select id from ecommerce_workflow where object_ID='")).append(news_ID).append("' and config_id<'").append(config_ID).append("' and    config_id>='").append(choice).append("'").toString();
								String sql;
								for (rs6 = ecommerce_db.executeQuery(sql6); rs6.next(); ecommerce_db1.executeUpdate(sql))
									sql = (new StringBuilder("update ecommerce_workflow set check_tag='0' where id='")).append(rs6.getString("id")).append("'").toString();

							}
							response.sendRedirect("ecommerce/news/check_delete_ok.jsp?finished_tag=3");
						} else
						{
							response.sendRedirect("ecommerce/news/check_delete_ok.jsp?finished_tag=2");
						}
					} else
					{
						response.sendRedirect("ecommerce/news/check_delete_ok.jsp?finished_tag=0");
					}
				} else
				{
					response.sendRedirect("ecommerce/news/check_delete_ok.jsp?finished_tag=1");
				}
				ecommerce_db.commit();
				ecommerce_db1.commit();
				ecommerce_db.close();
				ecommerce_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
